# Maintainer: Maxime Gauduin <alucryd@archlinux.org>

pkgname=libretro-pcsx2
pkgver=11900
pkgrel=2
pkgdesc='Sony PlayStation 2 core'
arch=(loong64 x86_64)
url=https://github.com/libretro/pcsx2
license=(
  GPL2
  GPL3
  LGPL2.1
  LGPL3
)
depends=(
  gcc-libs
  glibc
  libaio
  libgio-2.0.so
  libglib-2.0.so
  libglvnd
  libudev.so
  zlib
)
makedepends=(
  cmake
  git
  ninja
  png++
  systemd
)
_commit=373fca4dc5fbcb71970f0fa4a7f4c5501eeb83ee
source=(libretro-pcsx2::git+https://github.com/libretro/pcsx2.git#commit=${_commit})
b2sums=(SKIP)

pkgver() {
  cd libretro-pcsx2

  git rev-list --count HEAD
}

prepare() {
  sed '/set(CMAKE_C_COMPILER_LAUNCHER ccache)/d; /set(CMAKE_CXX_COMPILER_LAUNCHER ccache)/d' -i libretro-pcsx2/CMakeLists.txt
}

build() {
  #export LDFLAGS+=' -lgio-2.0'
  cmake -S libretro-pcsx2 -B build -G Ninja \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DDISABLE_ADVANCE_SIMD=ON \
    -DDISABLE_BUILD_DATE=ON \
    -DENABLE_TESTS=OFF \
    -DLIBRETRO=ON \
    -DSDL2_API=ON \
    -DREBUILD_SHADER=ON \
    -DUSE_LTO=ON \
    -DXDG_STD=ON \
    -Wno-dev
  ninja -C build
}

package() {
  install -Dm 644 build/pcsx2/pcsx2_libretro.so -t "${pkgdir}"/usr/lib/libretro/
}

# vim: ts=2 sw=2 et:
